<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>相对路径</title>

    <style>
        .one,.two,.three{
            width: 100px;
            height: 100px;
        }

        .one{
            background: blue;
        }

        .two{
            background: tomato;
            /*相对定位  会占据元素原有的位置*/
            position: relative;
            left: 100px;
            top: 100px;
        }

        .three{
            background: green;
        }

        .other{
            width: 200px;
            height: 200px;
            background: red;
            position: relative;
            left: 200px;
        }

        .inner{
            width: 100px;
            height: 100px;
            background: purple;
            /*这里的相对位置会相对于父类的*/
            position: relative;
            left: 100px;
            top: 100px;
        }

        .grand{
            width: 300px;
            height: 300px;
            background: yellow;
            position: relative;
            left: 400px;
        }

        .father{
            width: 200px;
            height: 200px;
            background: beige;
        }


        .son{
            width: 100px;
            height: 100px;
            background: tomato;
            /*这里只会相对于上一级的位置*/
            position: relative;
            left: 100px;
        }


    </style>

</head>
<body>


<div class="one"></div>
<div class="two"></div>
<div class="three"></div>

<div class="other">
    <div class="inner"></div>
</div>

<div class="grand">
    <div class="father">
        <div class="son"></div>
    </div>
</div>

</body>
</html>